<!doctype html>
<html lang="zh-CN">
<head>
  <!-- 必须的 meta 标签 -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
  <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>


  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.form/4.2.1/jquery.form.min.js"></script>


  <link href="https://cdn.bootcdn.net/ajax/libs/bootstrap-select/1.13.18/css/bootstrap-select.css" rel="stylesheet">
  <script src="https://cdn.bootcdn.net/ajax/libs/bootstrap-select/1.13.18/js/bootstrap-select.js"></script>
  <title>Hello, world!</title>
</head>
<body>
<div class="container-lg">

  <table class="table">
    <thead>
    <tr>
      <th scope="col">#</th>
      <th scope="col">赛事</th>
      <th scope="col">开始时间</th>
      <th scope="col">管理</th>
    </tr>
    </thead>
    <tbody>
    {assign name="index" value="0" /}

    {foreach $matchList as $key=>$match}
    <tr class="question">
      <th scope="row">{$index+=1}</th>
      <?php $href = "../match.matchController/matchDetail?mid=" . $match->mid; ?>
      <td><a href={$href}>{$match.match_name}</a></td>
      <td> {$match.start_time}</td>
      <td>
        <div class="mid" hidden >{$match->mid}</div>
        <button type="button" class="btn btn-primary manage">管理</button>
        <button type="button" class="btn btn-danger delete">删除</button>
      </td>
    </tr>
    {/foreach}
    </tbody>
  </table>

  <nav aria-label="Page navigation example">
    <ul class="pagination">
      <li class="page-item">
        <a class="page-link" href="#" aria-label="Previous">
          <span aria-hidden="true">&laquo;</span>
        </a>
      </li>
      {for start="1" end="$count / 10 + 1"}
      <?php $pagehref = "../admin.adminController/getMatch?page=" . $i; ?>
      <li class="page-item"><a class="page-link" href="{$pagehref}">{$i}</a></li>
      {/for}
      <li class="page-item">
        <a class="page-link" href="#" aria-label="Next">
          <span aria-hidden="true">&raquo;</span>
        </a>
      </li>
    </ul>
  </nav>
</div>

</body>
<script>



  $(".delete").click(function () {
    mid = $(this).prev().prev().text()

    $.post(
            "../admin.adminController/deleteMatch",
            {
              "mid": mid,
            },
            function (data,status) {
              alert(status)
              window.location = "../admin.adminController/getMatch?page=1"
            }
    )
  })

  $(".manage").click(function () {
    mid = $(this).prev().text()

    window.location = "../admin.adminController/toChangeMatch?mid="+mid
  })
</script>

</html>
